﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using SalesSys.Comm.Utility;
using SalesSys.DAL.Models;
using SalesSys.Service.Purchasing;
using SalesSys.WebCore;
using SalesSys.WebCore.Authorize;

namespace SalesSys.Site.Controllers.Api
{
    /// <summary>
    /// 采购管理
    /// </summary>
    public class PurchasingMngController : BaseApiController
    {
        private IPurchasingSvc purchasingSvc = new PurchasingSvc();

        /// <summary>
        /// 获取采购单列表
        /// </summary>
        /// <param name="name">采购单名称</param>
        /// <param name="state">采购单类型</param>
        /// <param name="page">分页</param>
        /// <param name="rows">每页条数</param>
        /// <returns></returns>
        public ViewDtos<PurchaseOrder> Get(string name = null, PurchaseOrder.PurchaseState? state = null, int page = 1, int rows = 10)
        {
            var data = purchasingSvc.GetList(name, state, null, page, rows);
            var dto = ViewDto.CreateList(data.Value);
            dto.Total = data.Key;
            dto.Page = page;
            dto.Rows = 10;
            return dto;
        }
    }
}
